import 'package:animal/constant/index_constant.dart';
import 'package:animal/item/message_list_item.dart';
import 'package:animal/ui/friend/controller/group_list_controller.dart';
import 'package:animal/utils/screen_util.dart';
import 'package:animal/widgets/PageStateWidget.dart';
import 'package:animal/widgets/appbar_widget.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

///群聊
class GroupListPage extends StatelessWidget {
  GroupListPage({Key? key}) : super(key: key);
  final GroupListController controller = Get.put(GroupListController());

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: KColorConstant.appBgColor,
      appBar: AppBarWidget.defaultAppBar(title: const Text("群聊"), elevation: 0, backgroundColor: Colors.white),
      body: Obx(() {
        return PageStateWidget.stateWidget(
          pageStatue: controller.pageState.value,
          emptyString: "暂无群聊哦~",
          emptyImage: "images/group_state.png",
          contentWidget: Column(
            children: [
              Container(height: ScreenUtil().L(20)),
              Expanded(
                child: SingleChildScrollView(
                  child: Container(
                    color: Colors.white,
                    child: Column(
                      children: [
                        Container(
                            margin: EdgeInsets.symmetric(horizontal: ScreenUtil().L(30), vertical: ScreenUtil().L(10)),
                            padding: EdgeInsets.symmetric(horizontal: ScreenUtil().L(20)),
                            height: ScreenUtil().L(35),
                            alignment: Alignment.center,
                            decoration: BoxDecoration(color: const Color(0XFFF6F6F6), borderRadius: BorderRadius.circular(ScreenUtil().L(40))),
                            child: Row(
                              children: [
                                Image.asset("icons/icon_search.png", width: ScreenUtil().L(18)),
                                Text(
                                  "搜索",
                                  style: KFontConstant.myTextStyle(size: 16, color: const Color(0XFFBFC4CC)),
                                )
                              ],
                            )),
                        ListView.builder(
                            itemCount: 20,
                            shrinkWrap: true,
                            physics: const NeverScrollableScrollPhysics(),
                            itemBuilder: (context, index) {
                              if (index == 19) {
                                return Container(
                                  alignment: Alignment.center,
                                  width: double.infinity,

                                  padding: EdgeInsets.only(top: ScreenUtil().L(15), bottom: ScreenUtil().L(50)),
                                  child: Text(
                                    "20个群聊",
                                    style: KFontConstant.myTextStyle(size: 14, color: const Color(0XFFA9A9A9)),
                                  ),
                                );
                              }
                              return const MessageListItem();
                            })
                      ],
                    ),
                  ),
                ),
              ),
            ],
          ),
        );
      }),
    );
  }
}
